<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
  </head>
  <body>
  
  <!--如下几个模块可以 根据情况组合  -->
  
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title" id="myModalLabel">用户注册</h4>
            </div>
            <form id="reg-form" class="form-horizontal" role="form">
            <div class="modal-body">
            	<jsp:include page="module/register.jsp"></jsp:include>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary" >注册</button>
            </div>
            </form>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
	</div>
  
  
  
  	<!--  登陆模块 -->
      <div class="SquarelyGreenContainer">
		<div class="top">
			<div class="bgbtop-center">
				<span><a href="">用户登录</a></span>
				<div class="WinRight"></div>
			</div>
		</div>
		<div class="Slot">
		    <form action="" name="userLogin" method="post" id='login-form'>
			      <table cellspacing="0" cellpadding="0" width="98%" align="center" border="0">
			          <tr>
			            <td align="center" colspan="2" height="10"></td>
			          </tr>
			          <tr>
			            <td align="right" width="31%" height="30" style="font-size: 11px;">用户名：</td>
			            <td align="left" width="69%"><input class="input" id="username1" title="用户名不能为空" size="11" name="userName" type="text" /></td>
			          </tr>
			          <tr>
			            <td align="right" height="30" style="font-size: 11px;">密　码：</td>
			            <td align="left"><input class="input" title="密码不能为空" type="password" size="12" id='password1' name="userPw"/></td>
			          </tr>
			          <tr>
			            <td align="center" colspan="2" height="10">
			            </td>
			          </tr>
			          <tr>
			            <td align="center" colspan="2" height="30">
			               <input type="button" id="login-button" value="登  录" style="border:#ccc 1px solid; background-color:#FFFFFF; font-size:12px; padding-top:3px;" />
						   <input type="button" id='register-button' value="注  册" style="border:#ccc 1px solid; background-color:#FFFFFF; font-size:12px; padding-top:3px;" />
			            </td>
			          </tr>
			      </table>
		    </form>
		    <div id='welcome' class='hidden' style="height:150px;">
		    	<span>欢迎您：<span id='username-show'></span></span>
		    	<br/>
		    	<br/>
		    	<span style="cursor: pointer;">
		    		<a id='login-out'>安全退出</a>
		    	</span>
		    </div>
		</div>
	 </div>
	 <script type="text/javascript" src="../js/public_fuc.js"></script>
	 <script type="text/javascript">
	 	//检查是否登陆
	 	var un = getCookie('username');
	 	if(isEmpty(un)){
	 		 $('#login-form').removeClass('hidden');
	  		 $('#welcome').addClass('hidden');
	 	}else{
	 		 $('#login-form').addClass('hidden');
	  		 $('#welcome').removeClass('hidden');
	  		 $('#username-show').text(un);
	 	}
	 
	 	
	 	$('#login-out').click(function(){
	 		deleteCookie('username');
	 		deleteCookie('userid');
	 		window.location.reload();
	 	});
	 	
	 
	 	$('#login-button').click(function(){
	    	  var obj = {};
	    	  var username = $('#username1').val();
			  if(isEmpty(username)){
				  alert('用户名不能为空');
				  return false;
			  }
			  obj.username = username;
			  obj.password = $('#password1').val();
			  
			  
			  //console.log($('#username1').val());
	    	  $.get("../api/user/list",obj,function(data){
	    	  	  console.log(data);
	    	  	  if (data.code==0) {
	    	  		  alert('登录成功');
	    	  		  $('#login-form').addClass('hidden');
	    	  		  $('#welcome').removeClass('hidden');
	    	  		  $('#username-show').text(username);
	    	  		  var arr = data.data;
	    	  		  setCookie('username', username);
	    	  		  setCookie('userid', arr[0].id);
	    		  }else{
	    			  alert('用户名或者密码不正确');
	    		  }
	    	  });
    		  return false;
	 	});
	 	$('#register-button').click(function(){
	    	console.log("ddd"); 
	    	$('#myModal').modal();
	 	});
	 	$('#reset-button').click(function(){
	 		$('#register-div').css('top','-3200px');
	 	});
	 	
	 </script>
	 
	 
	 
	 <!--  以上登陆模块 -->
	 
	 
	 
	 
	 
	 <!-- 查询模块 -->
	<div class="SquarelyGreenContainer">
		<div class="top">
			<div class="bgbtop-center">
				<span><a href="">商品查询</a></span>
				<div class="WinRight"></div>
			</div>
		</div>
		<div class="Slot" style="height: 40px;">
		    <form action="<%=path %>/goodsSearch.action" name="from1" method="post">
		        <table>
		            <tr>
		                <td>
		                    <input type="text" name="goodsName" size="10"/>
		                </td>
		                <td>
		                    <input type="submit" value="查询" style="border:#ccc 1px solid; background-color:#FFFFFF; font-size:12px; padding-top:3px;"/>
		                </td>
		            </tr>
		        </table>
		    </form>
		</div>
	 </div>
	 
	 
	 <!-- 类别模块  -->

  <%-- <div class="SquarelyGreenContainer">
    <div class="top">
        <div class="bgbtop-center">
            <span><a href="">商品类别</a></span>
            <div class="WinRight"></div>
        </div>
    </div>
    <div class="Slot">
         <jsp:include flush="true" page="/qiantai/module/catelogAll.jsp"></jsp:include>
    </div>
 </div> --%>
	
	 <script type="text/javascript">  
	  	
	  //这个页面是jsp:include 引用到 index页面 因此 变量名 方法名要唯一
		var obj = {};
		obj.page = 1;
		obj.number = 3;
		$.get("../api/complaints/list",obj,function(data){
			console.log(data);
			if (data.code==0) {
				var arr = data.data;
				var html = '';
				for (var i=0,len=arr.length;i<len;i++) {
					var obj = arr[i];
					html += '<tr id="'+obj.id+'">' 
						    +'<td>'+obj.reason+'</td>'
			               +'</tr>';
				}
				document.getElementById('bulletin').innerHTML = html;
			}
		});
	</script>
	 
	 
	 
	 <!-- 日历模块  -->
	 <div class="SquarelyGreenContainer">
		<div class="top">
			<div class="bgbtop-center">
				<span><a href="">日历表</a></span>
				<div class="WinRight"></div>
			</div>
		</div>
		<div class="Slot" style="height: 300px;">
		    <jsp:include flush="true" page="/qiantai/module/calendar.jsp"></jsp:include>
		</div>
	 </div>
  </body>
</html>
